package server;

import java.io.Serializable;

public class Map implements Serializable
{
	public Status array[][] = new Status[10][10];
	public Map()
	{
            	for (int i = 0; i < array.length ; i++)
			for (int j = 0; j < array[i].length ; j++)
			{
				array[i][j] = Status.EMPTY;
			}
	}
	public Map(int ship[], int  positions[])
	{
		for (int i = 0; i < array.length ; i++)
			for (int j = 0; j < array[i].length ; j++)
			{
				array[i][j] = Status.EMPTY;
			}
	}
	public enum Status
	{
		EMPTY(0),      //not have a point of ship
                HAVE(1),       //there is a part of ship
		HIT(2),        //the point was hitted by hostile
		MISS(3);        //the hostile attack is wrong
                int value;
                Status(int value)
                {
                    this.value = value;
                }

        public int getValue() {
            return value;
        }
                
	}
	public String toString()
	{
		String s = "";
		for (int i = 0; i < array.length ; i++)
                {
			for (int j = 0; j < array[i].length ; j++)
			{
				s += (array[i][j]==Status.EMPTY?"-":(array[i][j]==Status.HAVE?"X":"O"));
			}
                        s+="\n";
                }
		return s;
	}
        public int[][] getArray()
        {
            int [][] ar = new int[10][10];
            for (int i = 0; i < array.length ; i++)
                {
			for (int j = 0; j < array[i].length ; j++)
			{
                            ar[i][j] = array[i][j].getValue();
                        }
            }
            return ar;
        }
}
